﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MaLu.Data;
using System.Data;
using MaLu.Common;
using System.Xml;
using MaLu.BusiLogic;
using MaLu.Framework.Common;

namespace MaluJg.web.Visite
{
    public partial class item5v : VisitePage1
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {


                if (VisiteID != Guid.Empty)
                {

                    DataTable dt = SqlHelper.Instance.ExecuteDataTable(Provider, "select * from Visite where id ='" + VisiteID.ToString() + "'");
                    if (dt.Rows.Count > 0)
                    {


                        lbYear.Text = dt.Rows[0]["Year"].ToString();
                        lbMonth.Text = dt.Rows[0]["Month"].ToString();

                    }
                }
                BindData();
            }
        }
        private void BindData()
        {
            string projectname = string.Empty;
            string content = BLVisite.GetVisiteItem(Provider, VisiteID, "item5.aspx", ref projectname);
            if (content != string.Empty)
            {
                XmlDocument document = new XmlDocument();
                document.LoadXml(content);

                XmlElement xe = document.SelectSingleNode("//年2") as XmlElement;
                tbYear2.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//月2") as XmlElement;
                tbMonth2.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//日2") as XmlElement;
                tbDay2.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//问题") as XmlElement;

                XmlNodeList xnl = xe.ChildNodes;
                if (xnl.Count >= 1)
                {
                    tbP01.Text = xnl[0].Attributes["p1"].Value;
                    tbP02.Text = xnl[0].Attributes["p2"].Value;
                    tbP03.Text = xnl[0].Attributes["p3"].Value;
                    tbP04.Text = xnl[0].Attributes["p4"].Value;
                    cbP05.Checked = xnl[0].Attributes["p5"].Value == "True";
                    cbP06.Checked = xnl[0].Attributes["p6"].Value == "True";
                    cbP07.Checked = xnl[0].Attributes["p7"].Value == "True";
                    tbP08.Text = xnl[0].Attributes["p8"].Value;

                }

                if (xnl.Count >= 2)
                {
                    tbP11.Text = xnl[1].Attributes["p1"].Value;
                    tbP12.Text = xnl[1].Attributes["p2"].Value;
                    tbP13.Text = xnl[1].Attributes["p3"].Value;
                    tbP14.Text = xnl[1].Attributes["p4"].Value;
                    cbP15.Checked = xnl[1].Attributes["p5"].Value == "True";
                    cbP16.Checked = xnl[1].Attributes["p6"].Value == "True";
                    cbP17.Checked = xnl[1].Attributes["p7"].Value == "True";
                    tbP18.Text = xnl[1].Attributes["p8"].Value;
                }

                if (xnl.Count >= 3)
                {
                    tbP21.Text = xnl[2].Attributes["p1"].Value;
                    tbP22.Text = xnl[2].Attributes["p2"].Value;
                    tbP23.Text = xnl[2].Attributes["p3"].Value;
                    tbP24.Text = xnl[2].Attributes["p4"].Value;
                    cbP25.Checked = xnl[2].Attributes["p5"].Value == "True";
                    cbP26.Checked = xnl[2].Attributes["p6"].Value == "True";
                    cbP27.Checked = xnl[2].Attributes["p7"].Value == "True";
                    tbP28.Text = xnl[2].Attributes["p8"].Value;
                }

                if (xnl.Count >= 4)
                {
                    tbP31.Text = xnl[3].Attributes["p1"].Value;
                    tbP32.Text = xnl[3].Attributes["p2"].Value;
                    tbP33.Text = xnl[3].Attributes["p3"].Value;
                    tbP34.Text = xnl[3].Attributes["p4"].Value;
                    cbP35.Checked = xnl[3].Attributes["p5"].Value == "True";
                    cbP36.Checked = xnl[3].Attributes["p6"].Value == "True";
                    cbP37.Checked = xnl[3].Attributes["p7"].Value == "True";
                    tbP38.Text = xnl[3].Attributes["p8"].Value;
                }

                if (xnl.Count >= 5)
                {
                    tbP41.Text = xnl[4].Attributes["p1"].Value;
                    tbP42.Text = xnl[4].Attributes["p2"].Value;
                    tbP43.Text = xnl[4].Attributes["p3"].Value;
                    tbP44.Text = xnl[4].Attributes["p4"].Value;
                    cbP45.Checked = xnl[4].Attributes["p5"].Value == "True";
                    cbP46.Checked = xnl[4].Attributes["p6"].Value == "True";
                    cbP47.Checked = xnl[4].Attributes["p7"].Value == "True";
                    tbP48.Text = xnl[4].Attributes["p8"].Value;
                }

                if (xnl.Count >= 6)
                {
                    tbP51.Text = xnl[5].Attributes["p1"].Value;
                    tbP52.Text = xnl[5].Attributes["p2"].Value;
                    tbP53.Text = xnl[5].Attributes["p3"].Value;
                    tbP54.Text = xnl[5].Attributes["p4"].Value;
                    cbP55.Checked = xnl[5].Attributes["p5"].Value == "True";
                    cbP56.Checked = xnl[5].Attributes["p6"].Value == "True";
                    cbP57.Checked = xnl[5].Attributes["p7"].Value == "True";
                    tbP58.Text = xnl[5].Attributes["p8"].Value;
                }

                if (xnl.Count >= 7)
                {
                    tbP61.Text = xnl[6].Attributes["p1"].Value;
                    tbP62.Text = xnl[6].Attributes["p2"].Value;
                    tbP63.Text = xnl[6].Attributes["p3"].Value;
                    tbP64.Text = xnl[6].Attributes["p4"].Value;
                    cbP65.Checked = xnl[6].Attributes["p5"].Value == "True";
                    cbP66.Checked = xnl[6].Attributes["p6"].Value == "True";
                    cbP67.Checked = xnl[6].Attributes["p7"].Value == "True";
                    tbP68.Text = xnl[6].Attributes["p8"].Value;
                }

                if (xnl.Count >= 8)
                {
                    tbP71.Text = xnl[7].Attributes["p1"].Value;
                    tbP72.Text = xnl[7].Attributes["p2"].Value;
                    tbP73.Text = xnl[7].Attributes["p3"].Value;
                    tbP74.Text = xnl[7].Attributes["p4"].Value;
                    cbP75.Checked = xnl[7].Attributes["p5"].Value == "True";
                    cbP76.Checked = xnl[7].Attributes["p6"].Value == "True";
                    cbP77.Checked = xnl[7].Attributes["p7"].Value == "True";
                    tbP78.Text = xnl[7].Attributes["p8"].Value;
                }
                if (xnl.Count >= 9)
                {
                    tbP81.Text = xnl[8].Attributes["p1"].Value;
                    tbP82.Text = xnl[8].Attributes["p2"].Value;
                    tbP83.Text = xnl[8].Attributes["p3"].Value;
                    tbP84.Text = xnl[8].Attributes["p4"].Value;
                    cbP85.Checked = xnl[8].Attributes["p5"].Value == "True";
                    cbP86.Checked = xnl[8].Attributes["p6"].Value == "True";
                    cbP87.Checked = xnl[8].Attributes["p7"].Value == "True";
                    tbP88.Text = xnl[8].Attributes["p8"].Value;
                }
                if (xnl.Count >= 10)
                {
                    tbP91.Text = xnl[9].Attributes["p1"].Value;
                    tbP92.Text = xnl[9].Attributes["p2"].Value;
                    tbP93.Text = xnl[9].Attributes["p3"].Value;
                    tbP94.Text = xnl[9].Attributes["p4"].Value;
                    cbP95.Checked = xnl[9].Attributes["p5"].Value == "True";
                    cbP96.Checked = xnl[9].Attributes["p6"].Value == "True";
                    cbP97.Checked = xnl[9].Attributes["p7"].Value == "True";
                    tbP98.Text = xnl[9].Attributes["p8"].Value;
                }
            }

        }
      
    }
}
